// POSCheckDlg.h : header file
//

#pragma once
#include "ChildPageImp.h"

// CPOSCheckDlg dialog
typedef enum _EChildPage
{
    EPageHome,
    EPageSetting,
    EPageBurnin,
    EPageCheck,
    EPageHelp,
    EPageCount
}EChildPage;

class CPOSCheckDlg : public CDialog
{
// Construction
public:
	CPOSCheckDlg(CWnd* pParent = NULL);	// standard constructor
    virtual ~CPOSCheckDlg();

// Dialog Data
	enum { IDD = IDD_POSCHECK_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    
    // command handle functions
    afx_msg void OnBnClickedHome();
    afx_msg void OnBnClickedSetting();
    afx_msg void OnBnClickedBurnin();
    afx_msg void OnBnClickedCheck();
    afx_msg void OnBnClickedHelp();

    // Self defined message handle functions
    afx_msg LRESULT OnSysConfigUpdate(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCheckLineDisplay(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCheckPrinter(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCheckCashdrawer(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCheckMonitor(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCheckMSR(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCheckRFID(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnBurinStart(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnBurinEnd(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnBurinProgressUpdate(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnLinedisplayError(WPARAM wParam, LPARAM lParam) {m_arrayPages[EPageHome]->PostMessage(WM_LD_ERROR_OCCUR, wParam); return S_OK;}
    afx_msg LRESULT OnPrinterError(WPARAM wParam, LPARAM lParam) {m_arrayPages[EPageHome]->PostMessage(WM_PRINTER_ERROR_OCCUR, wParam); return S_OK;}
    afx_msg LRESULT OnCashdrawerError(WPARAM wParam, LPARAM lParam){m_arrayPages[EPageHome]->PostMessage(WM_CD_ERROR_OCCUR, wParam); return S_OK;}

    afx_msg LRESULT OnLDPTChecked(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnPrinterPTChecked(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnCDPTChecked(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnMonitorPTChecked(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnMSRPTChecked(WPARAM wParam, LPARAM lParam);

    DECLARE_MESSAGE_MAP()

private:
    BOOL InitCmdbar();
    BOOL InitChildPages();
    BOOL InitHomePage();
    BOOL InitSettingPage();
    BOOL InitBurninPage();
    BOOL InitCheckPage();
    BOOL InitHelpPage(){}
    void InitChildPagePosition(CRect &rect);
    
    void ShowChildPage(EChildPage ePage);

    void LogPTResult(EDeviceType eType, int nFlag = ES_Normal);

private:
    CBrush m_brushBk;
    CArray<CBitmapButton*> m_arrayTabBtns;
    CArray<CChildPage*> m_arrayPages;
    TSysConfig m_sysConfig;
};
